﻿using System;
using System.IO;

namespace Runner
{
    internal class Program
    {
        private const string SOLUTION_PARAM = "solution";
        private const string PATH_PARAM = "path";
        private const string FILE_PARAM = "file";

        public static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                PrintUsage();
                return;
            }

            var mode = args[0];
            var path = args[1];

            switch (mode)
            {
                case SOLUTION_PARAM:
                    // TODO
                    break;

                case PATH_PARAM:
                    if (!Directory.Exists(path))
                    {
                        Console.WriteLine("Ошибка: путь к исходным файлам не валиден");
                        return;
                    }
                    // TODO: enum dirs too
                    var sourceFilePaths = Directory.EnumerateFiles(path, "*.cs");
                    foreach (var sourceFilePath in sourceFilePaths)
                    {
                        CompilationChecker.Check(sourceFilePath);
                    }
                    break;

                case FILE_PARAM:
                    // TODO:
                    break;

                default:
                    PrintUsage();
                    break;
            }

            Console.WriteLine("Done. Press any key to exit.");
            Console.ReadKey();
        }

        private static void PrintUsage()
        {
            Console.WriteLine(string.Format("Runner.exe {0} file_name.sln - inspect solution", SOLUTION_PARAM));
            Console.WriteLine(string.Format("Runner.exe {0} path_name - inspect path", PATH_PARAM));
            Console.WriteLine(string.Format("Runner.exe {0} file_name - inspect file", FILE_PARAM));
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}
